<!DOCTYPE html>
<html lang="ch-ZN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p id="div1">点击</p>
</body>

<script>
var obj = {
    foo: function() { console.log(this.bar) },
    bar: 1,
};
 var foo = obj.foo;
 var bar = 2;

 obj.foo()

 foo()
</script>
</html>